local huanlong = fk.CreateSkill {
  name = "th_huanlong",
  max_phase_use_time = 1,
}

huanlong:addEffect("active", {
  anim_type = "offensive",
  prompt = "#th_huanlong",
  card_num = 0,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player and player:canPindian(to_select)
  end,
  target_num = 1,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local pindian = player:pindian({target}, huanlong.name)
    if pindian.results[target].winner ~= target and not target:hasSkill("th_yuekuang", true) then
      room:setPlayerMark(target, "@@th_yuekuang", 1)
      room:handleAddLoseSkills(target, "th_yuekuang", nil, true)
    end
    if pindian.results[target].winner ~= player and not player:hasSkill("th_yuekuang", true) then
      room:setPlayerMark(player, "@@th_yuekuang", 1)
      room:handleAddLoseSkills(player, "th_yuekuang", nil, true)
    end
  end
}, { check_skill_limit = true })

local cleaner = {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:getMark("@@th_yuekuang") ~= 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@@th_yuekuang", 0)
    player.room:handleAddLoseSkills(player, "-th_yuekuang", nil, true)
  end
}

huanlong:addEffect(fk.TurnEnd, cleaner)
huanlong:addEffect(fk.Death, cleaner)

Fk:loadTranslationTable{
  ["th_huanlong"] = "幻胧",
  [":th_huanlong"] = "出牌阶段限一次，你可以与一名角色拼点：没赢的角色获得〖月狂〗直到其回合结束。",

  ["#th_huanlong"] = "幻胧：与一名角色拼点，没赢的角色基本牌视为【杀】，锦囊牌视为【决斗】",

  ["@@th_yuekuang"] = "月狂",
}

return huanlong